<template>
	<view class="mainpadding2">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class="tupbox margin_top dingwei" @click="tzxq(item)" v-for="item in list.data" :key="item.id">
			<image :src="item.bg_image_text" mode=""></image>
			<view class="nkbtn weizhi" v-if="type == 2">{{item.price}}天/{{item.days}}天</view>
			<view class="nzti zitiwz">{{item.name}}</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				type: 1,//我的权益卡，2权益卡
				listid:"",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.type = options.type
			if (this.type == 1) {
				uni.setNavigationBarTitle({
					title:"我的权益卡"
				})
			} else if (this.type == 2) {
				uni.setNavigationBarTitle({
					title:"权益卡"
				})
			}
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					user_zbfapply_id:this.listid
				}
				let url = '/api/hyqycard/userHyqycardCard'
				if(this.type==2){//权益卡列表
					url="/api/hyqycard/getHyqycardIndex"
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 跳转详情
			tzxq(item) {
				let id = item.id
				// if(this.type==1){
				// 	id = item.card_id
				// }
				uni.navigateTo({
					url: '/pages_mypage/changdihuiyuankxq?id='+id+"&type="+this.type
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.ckzi {
		font-size: 44rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #576E8B;
	}

	.ykzt {
		font-size: 44rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #DC9253;
	}

	.jkzt {
		font-size: 44rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #E8A10C;
	}

	.zitiwz {
		position: absolute;
		top: 90rpx;
		left: 190rpx;
	}

	.ckbtn {
		background-color: #A1BCDE;
		border-radius: 0 30rpx 30rpx 0;
		font-size: 26rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 140rpx;
		height: 50rpx;
	}

	.nzti {
		font-size: 44rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #F5E1B5;
	}

	.ykbtn {
		background-color: #F9C99E;
		border-radius: 0 30rpx 30rpx 0;
		font-size: 26rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #F2892E;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 140rpx;
		height: 50rpx;
	}

	.jkbtn {
		background-color: #FFE8C0;
		border-radius: 0 30rpx 30rpx 0;
		font-size: 26rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #F8890A;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 140rpx;
		height: 50rpx;
	}

	.nkbtn {
		background-color: #D3B47D;
		border-radius: 0 30rpx 30rpx 0;
		font-size: 26rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #2D2113;
		display: flex;
		align-items: center;
		justify-content: center;
		// width: 140rpx;
		padding: 0 15rpx;
		height: 50rpx;
	}

	.weizhi {
		position: absolute;
		top: 30rpx;
		left: 0;
	}

	.tupbox {
		width: 100%;
		height: 240rpx;

		image {
			width: 100%;
			height: 100%;
			border-radius: 10rpx;
		}
	}
</style>